<template>
  <div class="order">
    <Theme :theme="theme"></Theme>
    <div class="content">
      <div class="content_top">
        <div id="nav_l" :class="{ current: currIdx == 0 }" @click="show(0)">
          全部
        </div>
        <div id="nav_m" :class="{ current: currIdx == 1 }" @click="show(1)">
          立等可取
        </div>
        <div id="nav_r" :class="{ current: currIdx == 2 }" @click="show(2)">
          预约订单
        </div>
      </div>
      <ul class="content_down">
        <li v-for="(card, i) in list" :key="i">
          <h4>
            <span>外卖</span>
            <p>{{ card.adress }}</p>
            <span>已取消</span
            ><i><van-icon name="delete-o" @click="del(i)" /></i>
          </h4>
          <div class="order_model">
            <img :src="card.goodsImg" alt="" />
            <p>{{ card.goodsName }}</p>
            <p>{{ card.goodsDescribe }}</p>
            <span>*{{ card.goodsNum }}</span>
          </div>
          <div class="order_bottom">
            <div>2021-08-14 12:13</div>
            <div>luckin coffee小程序</div>
            <div>共1件商品合计:￥27</div>
          </div>
          <button class="btn" @click="jump">再来一单</button>
        </li>
      </ul>
    </div>
  </div>
</template>

<script>
import axios from "axios";
import Theme from "../../components/lsc/theme.vue";
export default {
  components: { Theme },
  created() {
    this.getlist();
  },

  methods: {
    jump() {
      this.$router.push("/my");
    },
    show(index) {
      this.currIdx = index;
      this.getlist();
    },
    getlist() {
      //   axios({
      //     url: "http://localhost:3000/order",
      //     params: {
      //       type: this.types[this.currIdx],
      //     },
      //   }).then((res) => (this.list = res.data));
      // },
      // del(i) {
      //   axios({
      //     url: "http://localhost:3000/order",
      //     params: {
      //       type: "quan",
      //     },
      //   }).then((res) => console.log(res.data));
      //   console.log(i);
      axios({
        url: "/api/order/selectOrdersByUid/1",
      }).then((res) => {
        // console.log(res.data.data);
        res.data.data.forEach((item) => {
          // console.log(item.totalMoney);

          this.list.push(item.orderDetailResps[0]);
          // console.log(this.list);
        });
      });
    },
  },
  data() {
    return {
      theme: "订单列表",
      currIdx: 0,
      list: [],
      types: ["quan", "li", "yu"],
    };
  },
};
</script>

<style scoped>
.order {
  width: 100%;
  min-height: 6.4rem;
  background-color: #efeff4;
}
.content {
  padding-top: 0.46rem;
}
.content_top {
  width: 90%;
  margin: 0 auto;
  padding: 0.05rem;
  display: flex;
  border-radius: 0.3rem;
  justify-content: space-around;
  background-color: #6d86c4;
}
.content_top .current {
  background-color: #ffffff;
  color: #000 !important;
}
#nav_l,
#nav_m,
#nav_r {
  flex: 1;
  height: 0.4rem;
  line-height: 0.4rem;
  border-radius: 0.3rem;
  text-align: center;
  color: #fff;
}

.content_down {
  width: 90%;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-around;
}
.content_down li {
  width: 100%;
  margin: 0.04rem 0;
  border: 0.01rem solid #ccc;
  border-radius: 0.06rem;
  background-color: #fff;
}
.content_down li h4 {
  padding: 0.1rem;
  background-color: #fff;
  border-bottom: 1px solid #666;
}
.content_down li h4 span:nth-of-type(1) {
  display: inline-block;
  padding: 0.05rem;
  background-color: #7484bf;
  font-weight: normal;
  color: #fff;
  margin-right: 0.1rem;
  border-radius: 5px;
}
.content_down li h4 p {
  width: 1.6rem;
  line-height: 0.22rem;
  display: inline-block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.content_down li h4 span:nth-of-type(2) {
  display: inline-block;
  margin-left: 0.14rem;
  font-size: 0.14rem;
  border-right: 0.01rem solid #ccc;
  padding-right: 0.05rem;
}
.content_down li h4 i {
  margin-left: 0.02rem;
}
.order_model {
  padding: 0.05rem 0;
  position: relative;
}
.order_model img {
  width: 0.5rem;
  height: 0.5rem;
  margin-top: 0.05rem;
}
.order_model p {
  display: inline-block;
  position: absolute;
}
.order_model p:nth-of-type(1) {
  top: 0.15rem;
  left: 0.64rem;
  font-size: 0.18rem;
  font-weight: 700;
}
.order_model p:nth-of-type(2) {
  top: 0.42rem;
  left: 0.64rem;
  font-size: 0.14rem;
  color: #666;
}
.order_model span {
  position: absolute;
  top: 0.28rem;
  right: 0.16rem;
  color: #666;
}
.order_bottom {
  width: 100%;
  height: 0.5rem;
  line-height: 0.25rem;
  display: flex;
  justify-content: space-between;
}
.order_bottom div {
  font-size: 0.12rem;
  width: 1.06rem;
  height: 0.5rem;
  overflow: hidden;
  white-space: pre-wrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.btn {
  float: right;
  margin: 0.1rem 0.03rem 0.07rem 0;
  padding: 0.05rem;
  font-size: 0.14rem;
  color: #666;
  border: 0.01rem solid #666;
  border-radius: 0.3rem;
}
</style>